<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>公司汇总信息</title>

    <link rel="stylesheet" href="/static/css/heightlength.css">

    <link rel="stylesheet" href="/static/datetimepicker/css/bootstrap-datetimepicker.min.css">
    <style>
        body{
            /*width: 100%;*/
            height: 100%;
            margin-left: 1%;
            padding-left: 1%;
        }
        .container{
            height: 95%;
        }
        *{
            color: grey;
        }
        .form-control {

            width: 40%;
            /*margin-left: 12%;*/
            display: flex;
            flex-direction: column;
        }
    </style>
</head>

<body  style="background-color: whitesmoke; margin-left: 2%;">

        <div class="col-lg-12 ">
            <div class="mx-1">
                <span>当前位置>> <i id="show">单位汇总信息查询</i></span>
                <span id="ret" style="float: right;margin-right: 3%;color: black" hidden onclick="cl()"><a ><i>返回</i></a></span>
            </div>
        </div>
        <div class="col-lg-12" style="margin-top: 2%" id="tj">
<#--              <pre>-->
                  <span style="text-align: left">请选择查询条件</span>
                  <table width="100%" style="">
                      <tr>
                          <td colspan="4"></td>
                      </tr>
                      <tr>
                          <td style="text-align: right">开始时间:</td>
                          <td><input style="width: 40%" type="text" class="form-control form_datetime" id="statime" name="time"  placeholder=""></td>
                          <td style="text-align:right ">结束时间:</td>
                          <td><input type="text" style="width: 40%" class="form-control form_datetime" id="endtime" name="time" value=""  placeholder="" style="float: right"></td>
                      </tr>
                  </table>
                  <button onclick="cx()" style="margin-left: 20%">查询</button>

<#--            </pre>-->
        </div>
        <div  id="res" hidden>
                  <span style="">您输入的条件为：<i id="time"></i> &nbsp;&nbsp;共有<i id="count"></i>条数据</span>
                  <table style="width: 100%" border="1" cellpadding="0" cellspacing="0">
                      <thead>
                        <th>体检编码</th>
                      <th>身份证号</th>
                      <th width="70px">姓名</th>
                      <th width="40">性别</th>
                      <th width="40">年龄</th>
                      <th width="70px">在岗状态</th>
                      <th width="40">部门</th>
                      <th width="40">工号</th>
                      <th width="100px">体检日期</th>
                      <th>结论及建议</th>
                      </thead>
                      <tbody id="tb">

                      </tbody>
                  </table>
        </div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/bootstrap-datetimepicker.min.js"></script>
<script src="/static/js/bootstrap-datetimepicker.zh-CN.js"></script>

<script>
    $(function () {

        if (document.referrer=="") {
            $("#bb").hide();
            var hostname=location.hostname;
            var port=location.port;
            var trueUri="http://"+hostname+":"+port+"/dw/?sess=1"
            window.location.href=trueUri;
        }

        // alert(window.location.href);

    });
    $('.form_datetime').datetimepicker({
        minView: "month",  //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
        format : 'yyyy-mm-dd',//日期显示格式
       //  timeFormat:'',//时间显示格式
       //  todayBtn:  1,
        autoclose: 1,
        pickerPosition: 'bottom-right'

    });
    function cx() {
        debugger
        var start=$("#statime").val();
        var end=$("#endtime").val();
        if (start==end) {
            alert("开始时间和结束时间一致，请重新选择");
            return false;
        }
        if (pd(start,end)){
            $.ajax({
                url:'sel',
                type:'POST',
                data:{start:start,end:end},
                success:function (data) {
                    debugger;
                    if (data.status=="true"){
                        $("#show").text("公司体检查询结果");
                        $("#tj").hide();
                        $("#res").show();
                        $("#ret").show();
                        var str="";
                        $("#tb").empty();
                        $("#time").append(data.msg);
                        $("#count").append(data.data.length);
                        $.each(data.data,function(commendIndex,comment){
                            str +="<tr>"+
                                "<td>"+comment['tjbm']+"</td>"+
                                "<td>"+comment['idc']+"</td>"+
                                "<td><a href='../tj/my?idx="+comment['idx']+"' target='_blank' >"+comment['name']+"</td>"+
                                "<td>"+comment['sex']+"</td>"+
                                "<td>"+comment['age']+"</td>";
                            if (comment['wrkstanam']!=null) {
                               str+= "<td>" + comment['wrkstanam'] + "</td>" ;
                            }else {
                                str+="<td></td>";
                            }
                            if (comment['dpt']!=null) {
                                str+= "<td>" + comment['dpt'] + "</td>" ;
                            }else {
                                str+="<td></td>";
                            }
                            if (comment['wrknum']!=null) {
                                str+= "<td>" + comment['wrknum'] + "</td>" ;
                            }else {
                                str+="<td></td>";
                            }
                            if (comment['bhkdat']!=null) {
                                str+= "<td>" + comment['bhkdat'] + "</td>" ;
                            }else {
                                str+="<td></td>";
                            }
                            if (comment['tjjg']!=null || comment['jy']!=null){
                               str+= "<td>"+comment['tjjg']+"<br/>"+comment['jy']+"</td>"+
                                "</tr>";
                            }else {
                                str+='<td>本次体检未结束，暂不能查询</td></tr>';
                            }

                        });
                        $("#tb").append(str);
                        console.log(str);
                    }
                }
            })
        }else {
            alert("开始时间不能大于结束时间");
        }
    }
    function  cl() {
        $("#tb").empty();
        $("#res").hide();
        $("#tj").show();
        $("#ret").hide();
        $("#time").empty();
        $("#count").empty();
    }
function pd(start,end) {
    var startTmp = start.split("-");
    var endTmp = end.split("-");
    var stT = new Date(startTmp[0], startTmp[1], startTmp[2]);
    var edT = new Date(endTmp[0], endTmp[1], endTmp[2]);
    if (stT.getTime() >edT.getTime()) {
        //alert("开始日期不能大于或等于结束日期！");
        return false;
    }else {
        return true;
    }
}

</script>
</body>
</html>
